package org.jeecg.modules.middleware.rabbitmq;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.middleware.rabbitmq.delay.DelayMessageTypeEnum;
import org.jeecg.modules.middleware.rabbitmq.delay.DelayMqUtil;
import org.jeecg.modules.middleware.rabbitmq.delay.tl.TlDelayMessageType;
import org.jeecg.modules.middleware.rabbitmq.gen.EnumGenHandler;
import org.jeecg.modules.middleware.rabbitmq.gen.GenMqUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/testgenmq")
public class MqTestController {

    @GetMapping(value = "/test1")
    public Result<?> test1() {
        GenMqUtil.sendMsg(EnumGenHandler.WEBSOCKET_XXTS_HANDLER, "HY202210251658516201", "0");
        GenMqUtil.sendMsg(EnumGenHandler.TEST_HANDLER, "", "test111");
        return Result.error("111");
    }

    @GetMapping(value = "/test2")
    public Result<?> test2() {
        //延时消息测试
        DelayMqUtil.sendMsg(DelayMessageTypeEnum.TEST, "2", "gen2", 20); //延时12秒
        DelayMqUtil.sendMsg(DelayMessageTypeEnum.TEST, "1", "gen1", 10); //延时5秒

        DelayMqUtil.sendTLMsg(TlDelayMessageType.TEST,"test2",20);
        DelayMqUtil.sendTLMsg(TlDelayMessageType.TEST,"test",10);

        return Result.OK("success");
    }
}
